﻿using System;
using System.Configuration;
using System.IO;
using System.Text;
using System.Web;
using Vxr.Core;

namespace Vxr
{
    public class PR
    {
        public static string _sc = "server=112.213.84.113;database=GobalAMA;uid=crmama;;pwd=bacodon@123";

        public static string _scc =
            "U74ZgDq/0LJ7tV82B30PPTCu9M0gbt5Qr2ZtBCdBST11CqUhpX3me+mUeFmtVT1rFmlRtyTqy9u193fc4izy2mrf0zyes+2ynVAVa7EcplM=";
        //public static string _sc = "server=.\\SQLExpress;Trusted_Connection=Yes;database=VXR_BMS_001;";
        //for Account
        
        public static void rp(object obj, out object oo)
        {
            var x = new XR(obj); XR.Init(_sc, _scc);
            var r = x.R().A().LC().EX().LS1().LG().B().G();
            oo = r._d;
        }
        public static void CheckSizeFile(HttpContext c, StringBuilder sb, long s)
        {
            var path = string.Format("/Files/Reports/BaoCaoDoanhTHuChiTiet-{0}.xls", DateTime.UtcNow.ToBinary());
            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath("~" + path));
            sw.WriteLine(sb);
            c.Response.ContentType = "text/plain";
            if (sw.BaseStream.Length < s)
            {
                c.Response.Write(sb + "");
            }
            else
            {
                sw.Flush();
                c.Response.Write(string.Format("<a href='/service{0}'>Click vào đây để down báo cáo</a>", path));
            }
        }
    }
}
